import { View, Text } from "@tarojs/components";
import { Table } from "@nutui/nutui-react-taro";
import Popup from "@/components/Popup";

interface IProps {
  visible: boolean;
  billConfirmMsg: Array<{ text: string; value: string }>;
  tableData: Array<{
    project: string;
    unitPrice: string;
    dosage: string | number;
    expense: string | number;
  }>;
  title: string;
  onClose: () => any;
  onConfirm: () => any;
}

const ConfirmPopup = (props: IProps) => {
  const { visible, billConfirmMsg, tableData, title, onClose, onConfirm } =
    props;
  return (
    <Popup
      title={title}
      visible={visible}
      onClose={onClose}
      onConfirm={onConfirm}
    >
      {billConfirmMsg.map((item) => {
        return (
          <View className="bill-item-wrap">
            <Text className="bill-text">{item.text}</Text>
            <Text className="bill-value">{item.value}</Text>
          </View>
        );
      })}
      <Table
        columns={[
          {
            title: "项目",
            key: "project",
          },
          {
            title: "单价",
            key: "unitPrice",
          },
          {
            title: "用量",
            key: "dosage",
          },
          {
            title: "费用/元",
            key: "expense",
          },
        ]}
        data={tableData}
      />
    </Popup>
  );
};

export default ConfirmPopup;
